package com.longge;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-05-02 02:58
 */
public class Calculate {

    public int calculate(String s) {
        int x=1,y=0;
        char[] chars = s.toCharArray();
        for (char aChar : chars) {
            if (aChar=='A'){
                x = 2 * x + y;
            }else {
                y = 2 * y + x;
            }
        }
        return x+y;
    }
}
